using System;

namespace UraniaLib
{
	/// <summary>
	/// Summary description for UraniaEaster.
	/// </summary>
	public class UraniaEaster
	{
		public UraniaEaster()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public static void CalcEaster(int piYear, int piRetYear, int piRetMonth, int piRetDay)
		{
			double iA;
			double iB;
			double iC;
			double iD;
			double iE;
			double iFA;
			double iG;
			double iH;
			double iK;
			double iI;
			double iL;
			double iM;
			double iNA;
			double iP;

			iA = (piYear % 19);
			iB = Math.Floor(piYear / 100.0);
			iC = (piYear % 100);
			iD = Math.Floor(iB / 4.0);
			iE = (iB % 4);
			iFA = Math.Floor((iB + 8) / 25.0);
			iG = Math.Floor((iB - iFA + 1) / 3);
			iH = ((19 * iA) + iB - iD - iG + 15) % 30;
			iI = Math.Floor(iC / 4.0);
			iK = (iC % 4);
			iL = (32 + (2 * iE) + (2 * iI) - iH - iK) % 7;
			iM = Math.Floor((iA + (11 * iH) + (22 * iL)) / 451.0);
			iNA = Math.Floor((iH + iL - (7 * iM) + 114) / 31.0);
			iP = (iH + iL - (7 * iM) + 114) % 31;
			piRetYear = piYear;
			piRetMonth = Convert.ToInt16(iNA);
			piRetDay = Convert.ToInt16(iP + 1);
		}

		public static DateTime CalcEasterDateBetter(int piYear)
		{
			int iYear = 0;
			int iMonth = 0;
			int iDay = 0;
			DateTime dEaster = new DateTime();

			CalcEaster(piYear, iYear, iMonth, iDay);
			dEaster = new DateTime(iYear, iMonth, iDay);
			return dEaster;
		}

		public static DateTime CalcEasterDate(int piYear)
		{
			DateTime dEaster = new DateTime();

			double iA;
			double iB;
			double iC;
			double iD;
			double iE;
			double iFA;
			double iG;
			double iH;
			double iK;
			double iI;
			double iL;
			double iM;
			double iNA;
			double iP;

			iA = (piYear % 19);
			iB = Math.Floor(piYear / 100.0);
			iC = (piYear % 100);
			iD = Math.Floor(iB / 4.0);
			iE = (iB % 4);
			iFA = Math.Floor((iB + 8) / 25.0);
			iG = Math.Floor((iB - iFA + 1) / 3);
			iH = ((19 * iA) + iB - iD - iG + 15) % 30;
			iI = Math.Floor(iC / 4.0);
			iK = (iC % 4);
			iL = (32 + (2 * iE) + (2 * iI) - iH - iK) % 7;
			iM = Math.Floor((iA + (11 * iH) + (22 * iL)) / 451.0);
			iNA = Math.Floor((iH + iL - (7 * iM) + 114) / 31.0);
			iP = (iH + iL - (7 * iM) + 114) % 31;

			dEaster = new DateTime(piYear, Convert.ToInt16(iNA), Convert.ToInt16(iP + 1));
			return dEaster;
		}


	}
}
